<?php
/**
 * Created by PhpStorm.
 * User: zeopean
 * Date: 2015/8/24
 * Time: 14:02
 */
namespace App\Exceptions;

use Exception;

class InvestLogException extends Exception{
    /**
     * 参数解析
     *
     * NoUserIdAndOrgId         无用户标识、投资机构标识
     * NoInvestUserType         无明确的用户类型
     *
     */
    const NoUserIdAndOrgId      = 0x01;
    const NoInvestUserType      = 0x02;

    /**
     * @param $code
     * @param array $data
     * @param Exception $previous
     */
    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NoUserIdAndOrgId:
                $message = trans('exception.invest_log.no_user_id_and_org_id', ['user_id' => array_get($data,'user_id') , 'org_id' =>array_get($data , 'org_id') ]);
                break;

            case self::NoInvestUserType:
                $message = trans('exception.invest_log.no_invest_user_type', ['invest_user_type' => array_get($data, 'invest_user_type') ]);
                break;

            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}